package com.xiaoshuidi.cloud.module.member.controller.app;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.member.api.user.MemberUserApi;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserAuthInfoDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserReqDTO;
import com.xiaoshuidi.cloud.module.member.api.user.dto.MemberUserRespDTO;
import com.xiaoshuidi.cloud.module.member.enums.ApiConstants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping(ApiConstants.NAME)
@RestController
public class TestController {
    @Resource
    private MemberUserApi memberUserApi;
    @GetMapping("/test")
    public String test(){
         Long id = SecurityFrameworkUtils.getLoginUser().getId();
         Integer userType = SecurityFrameworkUtils.getLoginUser().getUserType();
         MemberUserReqDTO req = new MemberUserReqDTO();
         req.setName("张飞");
         req.setMobile("15556048023");
         req.setCardNo("342658458456120025");
         CommonResult<MemberUserRespDTO> userInfo = memberUserApi.getUserInfo(req);
         CommonResult<MemberUserAuthInfoDTO> userAuthInfo = memberUserApi.getUserAuthInfo("13696781620");
        return "id="+id+"userType="+userType;
    }
//    public static void main(String[] args) throws Exception {
//        String RSA_PRIVATE_KEY="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCd0h3rDr8ngnSge8id9biSf06RqaW0dewTJ05P3K2IdPVcYhKOgyOKrPiLXwxykIvE+DDZ3cjJ+eC1jbY7U0TfycYAo93JLYCduGatPZfN/gMudG9OjUXhZ7r6Fhc8bHfQW+bHk74ATpkC6pkWhWpGRZE+h5eTRtw0LwM0JH73u4nYajJDww3E2nMh8fkuO+6gprhR2YFgABWSQwbj3PVR7XpQSG+JfbkUa9DziE0c8fu2tU8Izj6aa4l4YYEqFo19fF/clFvgyGYNm1XFVh98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EEuXDBnB7kchTD/aMwhEb7D7eDjDWeUrsX0/2AyVjEGSn3DKQKBgHFpAjh+TSYPXqy8YUkrCCRfAhtMeuVF0OXxB9yptwl6/UetjjIkjbwtwxYM0lRWzsoAzmTieNbPzcHnPVHlGOrPtoo1c5QHUkt54YNF/utj/wl0x3gDNcfmgdziHilnjyXuF5yH//z8nbq/emjKyphVzxej6jmM+uylEF+r4RU0";
//        String  SIGNATURE_PUBLIC_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5NGQOURWKutTO+BjfJ4iVngdWLTW9SPg40ckL8dKHkesmhGMcoWXCjfoU/kDIQRV1qkq/AxRTNkjzh8IAslkM8Y6re+rk+prAyWQL8+/9s92DQXvrpBzMe1hkgWRP2HXlAY8wwCebA5MYAowwwQv0uvQ7tkvOeEzmbcKoNahiaporWnNJ7CZ9RCmF/OzuhholHV1wT3Gc+QcDeJaAodBEOLPcnvHyt1ZnqLeTFHNc9v8QMRr7VGWBdUJ7nt6xGqhmnVk+Nk8urmprB3vHWR26F7ONzIwwcVrDLfJpC4mWhe5y0N251aiEh5JBm6GrHov01nm8P/7Ny0EpTJ+zEx61wIDAQAB";
//        String ciphertext="ESXTRC8//igSzPseCnCVT6ejTIytwGdQNzxcFX9ErgDrYhHRL3NKWGgKKFTF3vT9D7ruS3SznDIsFjTWvJI9F0XQDhqmDZUbH7PLnZYZm9iR1mzh9l7wL1SuE88Jb5MZyxnPzUkw6mTh+rOVE7mWwXQ8HtTjTVgUkMQYQr/RpojQtVRWjVYel9NCXAw5f9OiMr0FfQBSkg5/Mb3MNqeXY7aFMFN0ljXMwq8rpsru3o23tOHjaezlY+2qLrP2AmrEWKBulsU5Tnv5BSK3vPflRGjzrXpCqjecXG87JsFXhGlVdVnXj25xr3g/e+RKS7u3RhepGBPaZzyGjjioKL6qDQ==";
//        String signString="FWJK3ItRa7Yg8mFXpUhZPJIWpUrpq40+0Y1t2giE/N6VN9LszhsNwVNRjPNkyUHkJG7x9V59fuW5abrz58v0P3dTSpQmqvuHbY6p0LB89XfEvIytehtr3PxTHixlpGLikcnLNzfypuICNWy+YTlN9thZkLMS/zeWfHFu9Mr45awcMsKzIS1OFwiy/bHDBWn5W9/qnF4hbeQMAIhVUPaf6rL0fcomxTNgU5IilvcJV4MvoFDZ5OgBe9+MNyrsq/l8UtPzuLzaNfZkHoc2emRGZYYE29vF5h5UXP090NA5MsuAjgWaNwBmDQaqJM77nG338myVYOLk9ZaFsOXsvDTP/w==";
//        String decrypt = RSAEncryptUtil.decrypt(ciphertext, Base64.decodeBase64(RSA_PRIVATE_KEY));
//        System.out.println(decrypt);
//        LoginInfo loginInfo = JSONObject.parseObject(decrypt,LoginInfo.class);
//        System.out.println(loginInfo);
//        String content = loginInfo.getUserId() + loginInfo.getAccessToken() + loginInfo.getRefreshToken() + loginInfo.getTenantId();
//
//        boolean verifySignature2 = DigitalSignatureUtil.verifySignature(content, signString, Base64.decodeBase64(SIGNATURE_PUBLIC_KEY));
//        System.out.println(verifySignature2);
//    }
}
